import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;

import java.util.Arrays;
import java.util.Collection;

import static org.junit.Assert.assertEquals;

@RunWith(Parameterized.class)
public class TriangleTest {
    Triangle triangle ;
    public String expected;
    public Object[] sides = null;

    public TriangleTest(String expected,Object[] sides){
        this.expected = expected;
        this.sides = sides;
    }

    @Before
    public void init(){
        triangle = new Triangle();
    }

    @Parameterized.Parameters
    public static Collection<Object[]> date() {
        return Arrays.asList(new Object[][]{
                        {"输入错误", new Object[]{1.5,1.1,5}},//非整数
                        {"输入错误", new Object[]{3,4,5,1}},//参数个数大于3
                        {"输入错误", new Object[]{1,1}},//参数个数小于3
                        {"输入错误", new Object[]{-1,1,1}},//参数小于1
                        {"输入错误", new Object[]{100,110,60}},//参数大于100
                        {"输入错误", new Object[]{1.1,110,60}},//参数大于100且非整数
                        {"非三角形", new Object[]{3,3,6}},//两边之和等于第三边
                        {"非三角形", new Object[]{1,1,5}},//两边之和小于第三边
                        {"等边三角形", new Object[]{1,1,1}},
                        {"等边三角形", new Object[]{100,100,100}},
                        {"等腰三角形", new Object[]{4,4,5}},
                        {"等腰三角形", new Object[]{4,4,7}},
                        {"一般三角形", new Object[]{3,4,5}},
                        {"一般三角形", new Object[]{2,4,5}},
                        {"一般三角形", new Object[]{3,7,5}},
                }
        );
    }

    @Test
    public void isTriangle() {
        assertEquals(expected,triangle.isTriangle(sides));
    }
}